package com.lnt.spring.metadata;

import com.lnt.spring.service.InterfaceServiceTest;
import com.lnt.spring.service.imgl.InterfaceServiceImglTest;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;

import java.io.IOException;

/**
 * @title : 测试类
 * @createDate : 2021-11-16 09:42
 * @creater : LuNanTing
 * @className : JavaTest
 */
public class JavaTest {

    public static void main(String[] args) throws IOException {
        InterfaceServiceImglTest son = new InterfaceServiceImglTest();
//        PenetrateTest test = new PenetrateTest();
//        PenetrateParent parent = new PenetrateParent();
        System.out.println(son instanceof InterfaceServiceTest);
        System.out.println(son instanceof InterfaceServiceTest);

        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
        MetadataReader metadataReader = cachingMetadataReaderFactory.getMetadataReader(son.getClass().getName());
        for (String interfaceName : metadataReader.getClassMetadata().getInterfaceNames()) {
            System.out.println("接口:" + interfaceName);
        }

        boolean isInterface = metadataReader.getClassMetadata().isInterface();
        System.out.println("是否是接口:" + isInterface);

        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        for (String interfaceName : annotationMetadata.getInterfaceNames()) {
            System.out.println("实现的所有接口:" + interfaceName);
        }
    }
}
